package lab02.Test13;

/**
 * Created by Administrator on 2017/10/21.
 */
public class Gymnastics extends ComputerAverage{
    double []data;
    Gymnastics(double []data){
                this.data=data;
         }
  double average(double []data) {
             double max,min;
             int a1=0,a2=0;
              max=min=data[0];
              for(int i=0;i<data.length;i++){
                        if(data[i]>max){
                               max=data[i];
                            a1=i;
                           }
                      else if(data[i]<min){
         min=data[i];
    a2=i;
      }
                 }
                 data[a1]=0;
                data[a2]=0;
               double sum=0;
        for(int i=0;i<data.length;i++){
         sum+=data[i];
        }
           sum=sum/(data.length-2);
           return sum;
        }
        }
